package invocation;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyHandler implements InvocationHandler {
    Object target = null;
    public MyHandler(Object target){
            this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        Object res = null;
        // 向厂家发送订单，告诉厂家
        res = method.invoke(target,args);

        // 返回对象不为空
        // 商家加价后返回
        if (res!=null){
           res = 20.0f + (Float) res;
        }
        System.out.println("添加优惠juan");
        // 返回增加的方法
        return res;
    }
}
